/*
 * @Author: 詹真琦(legendryztachi@gmail.com)
 * @Date: 2022-05-24 10:18:28
 * @LastEditors: 詹真琦(legendryztachi@gmail.com)
 * @LastEditTime: 2022-06-16 18:05:55
 * @FilePath: \code\ctp-static-portal-front\src\components\helper.js
 * @Description:
 */
/**
 * @description: 传入栏目类型，满足条件就执行回调
 * @param {String} resolveFunction 栏目类型
 * @param {function} cb 满足条件就执行函数
 * @return {String}栏目高度css
 */
export function checkPanelAndSet(resolveFunction, cb) {
  // console.log(resolveFunction);

  switch (resolveFunction) {
    //多图平铺1、多图滚动、图片+标题、标题摘要、卡片式高度自动撑开
    case 'multiPictureScrollingTemplate':
    case 'morePictureTemplete':
    case 'pictureTitleSimpleTemplete':
    case 'pictureTitleAndBriefTemplete':
    case 'pictureCardTemplete':
      //有函数就执行
      cb && cb(`height:auto;min-height:150px`);
  }
}

/**
 * @description: 判断当前应该展示几条数据
 * @param {Number} lineHeight 每一行多高
 * @param {Number} panelHeight 整个栏目多高
 * @return {Number}返回能展示几条数据
 */
export function getListCount(panelHeight, lineHeight = 32) {
  return Math.floor(panelHeight / lineHeight);
}
